#include <vector>
using namespace std;
class Solution
{
public:
    int missingNumber(vector<int> &nums)
    {
        int left = 0, right = nums.size() - 1;
        // if(right == 0) return nums[left] ? 0 : 1;
        while (left < right)
        {
            int mid = left + right >> 1;
            if (nums[mid] == mid)
                left = mid + 1;
            else
                right = mid;
        }
        return nums[left] == left ? left + 1 : left;
    }
};